﻿@using System.Text
@typeparam TValue
@inherits Blazorise.Check<TValue>
@if ( ParentIsAddons )
{
    <span class="@AddonClassNames">
        @InputElement
    </span>
}
else
{
    <span class="@InputClassNames">
        @InputElement
    </span>
}
@Feedback
@code {
    bool IsChecked => string.Compare( CurrentValueAsString ,bool.TrueString, StringComparison.InvariantCultureIgnoreCase ) == 0;

    private RenderFragment InputElement => __builder =>
    {
        <input @ref="@ElementRef" id="@ElementId" type="checkbox" name="@Name" class="@ClassNames" style="@StyleNames" disabled="@Disabled" readonly="@ReadOnly" checked="@CurrentValue" tabindex="@TabIndex" @onchange="@OnChangeHandler" @onkeydown="@OnKeyDownHandler" @onkeypress="@OnKeyPressHandler" @onkeyup="@OnKeyUpHandler" @onblur="@OnBlurHandler" @onfocus="@OnFocusHandler" @onfocusin="@OnFocusInHandler" @onfocusout="@OnFocusOutHandler" @attributes="@Attributes" />
        <div aria-hidden="true" class="fui-Checkbox__indicator">
            <svg fill="currentColor" class="fui-Checkbox__icon" aria-hidden="true" width="12" height="12" viewBox="0 0 12 12" xmlns="http://www.w3.org/2000/svg"><path d="M9.76 3.2c.3.29.32.76.04 1.06l-4.25 4.5a.75.75 0 0 1-1.08.02L2.22 6.53a.75.75 0 0 1 1.06-1.06l1.7 1.7L8.7 3.24a.75.75 0 0 1 1.06-.04Z" fill="currentColor"></path></svg>
        </div>
        <label for="@ElementId" class="fui-Label fui-Checkbox__label">
            @ChildContent
        </label>
    };
}